package com.qf.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.qf.mapper.DtsGoodsSpecificationMapper;
import com.qf.pojo.DtsGoodsSpecification;
import com.qf.service.DtsGoodsSpecificationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * @author ZhangYuJie
 * projectName:shop_manage
 * time:2022/5/17 21:21
 * description:
 */
@Service
public class DtsGoodsSpecificationServiceImpl implements DtsGoodsSpecificationService {

    @Autowired
    private DtsGoodsSpecificationMapper goodsSpecificationMapper;

    @Override
    public List<DtsGoodsSpecification> queryByGid(Integer id) {
        QueryWrapper<DtsGoodsSpecification> wapper = new QueryWrapper<>();
        wapper.eq("deleted", false);
        wapper.eq("goods_id", id);
        return goodsSpecificationMapper.selectList(wapper);
    }

    @Override
    public void deleteByGid(Integer gid) {
        QueryWrapper<DtsGoodsSpecification> wapper = new QueryWrapper<>();
        wapper.eq("goods_id", gid);
        goodsSpecificationMapper.delete(wapper);
    }

    @Override
    public void add(DtsGoodsSpecification goodsSpecification) {
        goodsSpecification.setAddTime(new Date());
        goodsSpecification.setUpdateTime(new Date());
        goodsSpecificationMapper.insert(goodsSpecification);
    }
}
